package org.example.footshoppingmaster.service.impl;

import org.example.footshoppingmaster.mapper.ProductMapper;
import org.example.footshoppingmaster.pojo.DO.Product;
import org.example.footshoppingmaster.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;

    @Override
    /*
     * 根据商品type：man women chile
     *        brand：Nike 彪马
     * 来查询商品
     * */
    public List<Product> selectGoods(String type,String brand,Integer page,Integer pageSize) {
        int numFrom =(page-1)*pageSize;
        return productMapper.selectByType(type,brand,numFrom,pageSize);
    }
    /*
     * 根据商品id来查询
     * */
    @Override
    public Product selectGoodById(Integer id) {
        return productMapper.selectById(id);
    }

    /*
    * 查询商品总数
    * */
    @Override
    public Integer selectGoodsSum(String type, String brand) {
        return productMapper.selectNum(type,brand);
    }
    /*
     * 根据ids查询商品总数
     * */
    @Override
    public List<Product> selectGoodsByIds(List<Integer> ids) {
        return productMapper.selectByIds(ids);
    }
}
